﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Media;
using System.Xml;


namespace DoAn
{
    public partial class FormChinh : Form
    {
        //Am nhac
        private SoundPlayer BackgroundMusic;
        private bool SoundEnable;
       
       
        public FormChinh()
        {
            InitializeComponent();
            
        }

        private void btnTaodethi_Click(object sender, EventArgs e)
        {
            FormDangNhap frmdangnhap = new FormDangNhap();
            frmdangnhap.ShowDialog();
        }

        private void btnBatdau_Click(object sender, EventArgs e)
        {
            FormThongTin frmthongtin = new FormThongTin();
            frmthongtin.ShowDialog();
        }

        private void btnBangxephang_Click(object sender, EventArgs e)
        {
            FormXepHang frm = new FormXepHang();
            frm.ShowDialog();
        }

        private void btnTuychinh_Click(object sender, EventArgs e)
        {
            pnlOptions.Visible = true;
        }

        private void btnHidePanel_Click(object sender, EventArgs e)
        {
            if (rdbMusicOn.Checked)
            {
                Options(rdbMusicOn.Checked);
            }
            else
            {
                BackgroundMusic.Stop();
            }
            pnlOptions.Visible = false;
        }

        private void FormChinh_FormClosing(object sender, FormClosingEventArgs e)
        {
            DialogResult dr = MessageBox.Show("Ban có muốn thoát không?", "Thoát chương trình", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
            if (dr == DialogResult.Cancel)
            {
                e.Cancel = true;
            }
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        //ham options 
        public void Options(bool Sound)
        {
            SoundEnable = Sound;
            if (SoundEnable)
            {
                if (BackgroundMusic == null)
                {
                    BackgroundMusic = new SoundPlayer();
                    BackgroundMusic.Stream = DoAn.Properties.Resources.chimes;
                    BackgroundMusic.PlayLooping();
                }
            }
        }

       

        private void FormChinh_Load(object sender, EventArgs e)
        {
           
        }

        
    }
}